home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / a_utils / perl / mac-perl / mcprl401.bin / Perl_appl / lib / newgetopt.pl < prev    next >
MacBinary  |  1992-09-27  |  8.3 KB  |  [TEXT/MPS ]

open in: MacOS 8.1     |     Win98     |     DOS

browse contents    |     view JSON data     |     view as text


This file was processed as: MacBinary (archive/macBinary).

ConfidenceProgramDetectionMatch TypeSupport
10% dexvert MacBinary (archive/macBinary) fallback Supported
1% dexvert Text File (text/txt) fallback Supported
100% file MacBinary II, Sun Sep 27 18:02:23 1992, modified Sun Sep 27 18:02:23 1992, creator 'MPS ', type ASCII, 7685 bytes "newgetopt.pl" , at 0x1e85 428 bytes resource default (weak)
99% file data default
74% TrID Macintosh plain text (MacBinary) default
25% TrID MacBinary 2 default (weak)
100% siegfried fmt/1762 MacBinary (II) default
100% lsar MacBinary default


id metadata
keyvalue
macFileType[TEXT]
macFileCreator[MPS ]



hex view
+--------+-------------------------+-------------------------+--------+--------+
|00000000| 00 0c 6e 65 77 67 65 74 | 6f 70 74 2e 70 6c 00 00 |..newget|opt.pl..|
|00000010| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000020| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000030| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000040| 00 54 45 58 54 4d 50 53 | 20 00 00 00 00 00 00 00 |.TEXTMPS| .......|
|00000050| 00 00 00 00 00 1e 05 00 | 00 01 ac a6 eb df ef a6 |........|........|
|00000060| eb df ef 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000070| 00 00 00 00 00 00 00 00 | 00 00 81 81 89 3d 00 00 |........|.....=..|
|00000080| 23 20 6e 65 77 67 65 74 | 6f 70 74 2e 70 6c 20 2d |# newget|opt.pl -|
|00000090| 2d 20 6e 65 77 20 6f 70 | 74 69 6f 6e 73 20 70 61 |- new op|tions pa|
|000000a0| 72 73 69 6e 67 0d 0d 23 | 20 53 43 43 53 20 53 74 |rsing..#| SCCS St|
|000000b0| 61 74 75 73 20 20 20 20 | 20 3a 20 40 28 23 29 40 |atus | : @(#)@|
|000000c0| 20 6e 65 77 67 65 74 6f | 70 74 2e 70 6c 09 31 2e | newgeto|pt.pl.1.|
|000000d0| 31 33 0d 23 20 41 75 74 | 68 6f 72 20 20 20 20 20 |13.# Aut|hor |
|000000e0| 20 20 20 20 20 3a 20 4a | 6f 68 61 6e 20 56 72 6f | : J|ohan Vro|
|000000f0| 6d 61 6e 73 0d 23 20 43 | 72 65 61 74 65 64 20 4f |mans.# C|reated O|
|00000100| 6e 20 20 20 20 20 20 3a | 20 54 75 65 20 53 65 70 |n :| Tue Sep|
|00000110| 20 31 31 20 31 35 3a 30 | 30 3a 31 32 20 31 39 39 | 11 15:0|0:12 199|
|00000120| 30 0d 23 20 4c 61 73 74 | 20 4d 6f 64 69 66 69 65 |0.# Last| Modifie|
|00000130| 64 20 42 79 3a 20 4a 6f | 68 61 6e 20 56 72 6f 6d |d By: Jo|han Vrom|
|00000140| 61 6e 73 0d 23 20 4c 61 | 73 74 20 4d 6f 64 69 66 |ans.# La|st Modif|
|00000150| 69 65 64 20 4f 6e 3a 20 | 54 75 65 20 4a 75 6e 20 |ied On: |Tue Jun |
|00000160| 20 32 20 31 31 3a 32 34 | 3a 30 33 20 31 39 39 32 | 2 11:24|:03 1992|
|00000170| 0d 23 20 55 70 64 61 74 | 65 20 43 6f 75 6e 74 20 |.# Updat|e Count |
|00000180| 20 20 20 3a 20 37 35 0d | 23 20 53 74 61 74 75 73 | : 75.|# Status|
|00000190| 20 20 20 20 20 20 20 20 | 20 20 3a 20 4f 6b 61 79 | | : Okay|
|000001a0| 0d 0d 23 20 54 68 69 73 | 20 70 61 63 6b 61 67 65 |..# This| package|
|000001b0| 20 69 6d 70 6c 65 6d 65 | 6e 74 73 20 61 20 6e 65 | impleme|nts a ne|
|000001c0| 77 20 67 65 74 6f 70 74 | 20 66 75 6e 63 74 69 6f |w getopt| functio|
|000001d0| 6e 2e 20 54 68 69 73 20 | 66 75 6e 63 74 69 6f 6e |n. This |function|
|000001e0| 20 61 64 68 65 72 65 73 | 0d 23 20 74 6f 20 74 68 | adheres|.# to th|
|000001f0| 65 20 6e 65 77 20 73 79 | 6e 74 61 78 20 28 6c 6f |e new sy|ntax (lo|
|00000200| 6e 67 20 6f 70 74 69 6f | 6e 20 6e 61 6d 65 73 2c |ng optio|n names,|
|00000210| 20 6e 6f 20 62 75 6e 64 | 6c 69 6e 67 29 2e 0d 23 | no bund|ling)..#|
|00000220| 0d 23 20 41 72 67 75 6d | 65 6e 74 73 20 74 6f 20 |.# Argum|ents to |
|00000230| 74 68 65 20 66 75 6e 63 | 74 69 6f 6e 20 61 72 65 |the func|tion are|
|00000240| 3a 0d 23 0d 23 20 20 2d | 20 61 20 6c 69 73 74 20 |:.#.# -| a list |
|00000250| 6f 66 20 70 6f 73 73 69 | 62 6c 65 20 6f 70 74 69 |of possi|ble opti|
|00000260| 6f 6e 73 2e 20 54 68 65 | 73 65 20 73 68 6f 75 6c |ons. The|se shoul|
|00000270| 64 20 64 65 73 69 67 6e | 61 74 65 20 76 61 6c 69 |d design|ate vali|
|00000280| 64 20 70 65 72 6c 0d 23 | 20 20 20 20 69 64 65 6e |d perl.#| iden|
|00000290| 74 69 66 69 65 72 73 2c | 20 6f 70 74 69 6f 6e 61 |tifiers,| optiona|
|000002a0| 6c 6c 79 20 66 6f 6c 6c | 6f 77 65 64 20 62 79 20 |lly foll|owed by |
|000002b0| 61 6e 20 61 72 67 75 6d | 65 6e 74 20 73 70 65 63 |an argum|ent spec|
|000002c0| 69 66 69 65 72 20 28 22 | 3d 22 0d 23 20 20 20 20 |ifier ("|=".# |
|000002d0| 66 6f 72 20 6d 61 6e 64 | 61 74 6f 72 79 20 61 72 |for mand|atory ar|
|000002e0| 67 75 6d 65 6e 74 73 20 | 6f 72 20 22 3a 22 20 66 |guments |or ":" f|
|000002f0| 6f 72 20 6f 70 74 69 6f | 6e 61 6c 20 61 72 67 75 |or optio|nal argu|
|00000300| 6d 65 6e 74 73 29 20 61 | 6e 64 20 61 6e 0d 23 20 |ments) a|nd an.# |
|00000310| 20 20 20 61 72 67 75 6d | 65 6e 74 20 74 79 70 65 | argum|ent type|
|00000320| 20 73 70 65 63 69 66 69 | 65 72 3a 20 22 6e 22 20 | specifi|er: "n" |
|00000330| 6f 72 20 22 69 22 20 66 | 6f 72 20 69 6e 74 65 67 |or "i" f|or integ|
|00000340| 65 72 20 6e 75 6d 62 65 | 72 73 2c 20 22 66 22 20 |er numbe|rs, "f" |
|00000350| 66 6f 72 0d 23 20 20 20 | 20 72 65 61 6c 20 28 66 |for.# | real (f|
|00000360| 69 78 29 20 6e 75 6d 62 | 65 72 73 20 6f 72 20 22 |ix) numb|ers or "|
|00000370| 73 22 20 66 6f 72 20 73 | 74 72 69 6e 67 73 2e 0d |s" for s|trings..|
|00000380| 23 20 20 20 20 49 66 20 | 61 6e 20 22 40 22 20 73 |# If |an "@" s|
|00000390| 69 67 6e 20 69 73 20 61 | 70 70 65 6e 64 65 64 2c |ign is a|ppended,|
|000003a0| 20 74 68 65 20 6f 70 74 | 69 6f 6e 20 69 73 20 74 | the opt|ion is t|
|000003b0| 72 65 61 74 65 64 20 61 | 73 20 61 6e 20 61 72 72 |reated a|s an arr|
|000003c0| 61 79 2e 0d 23 20 20 20 | 20 56 61 6c 75 65 28 73 |ay..# | Value(s|
|000003d0| 29 20 61 72 65 20 6e 6f | 74 20 73 65 74 2c 20 62 |) are no|t set, b|
|000003e0| 75 74 20 70 75 73 68 65 | 64 2e 0d 23 0d 23 20 20 |ut pushe|d..#.# |
|000003f0| 2d 20 69 66 20 74 68 65 | 20 66 69 72 73 74 20 6f |- if the| first o|
|00000400| 70 74 69 6f 6e 20 6f 66 | 20 74 68 65 20 6c 69 73 |ption of| the lis|
|00000410| 74 20 63 6f 6e 73 69 73 | 74 73 20 6f 66 20 6e 6f |t consis|ts of no|
|00000420| 6e 2d 61 6c 70 68 61 6e | 75 6d 65 72 69 63 0d 23 |n-alphan|umeric.#|
|00000430| 20 20 20 20 63 68 61 72 | 61 63 74 65 72 73 20 6f | char|acters o|
|00000440| 6e 6c 79 2c 20 69 74 20 | 69 73 20 69 6e 74 65 72 |nly, it |is inter|
|00000450| 70 72 65 74 65 64 20 61 | 73 20 61 20 67 65 6e 65 |preted a|s a gene|
|00000460| 72 69 63 20 6f 70 74 69 | 6f 6e 20 73 74 61 72 74 |ric opti|on start|
|00000470| 65 72 2e 0d 23 20 20 20 | 20 45 76 65 72 79 74 68 |er..# | Everyth|
|00000480| 69 6e 67 20 73 74 61 72 | 74 69 6e 67 20 77 69 74 |ing star|ting wit|
|00000490| 68 20 6f 6e 65 20 6f 66 | 20 74 68 65 20 63 68 61 |h one of| the cha|
|000004a0| 72 61 63 74 65 72 73 20 | 66 72 6f 6d 20 74 68 65 |racters |from the|
|000004b0| 20 73 74 61 72 74 65 72 | 0d 23 20 20 20 20 77 69 | starter|.# wi|
|000004c0| 6c 6c 20 62 65 20 63 6f | 6e 73 69 64 65 72 65 64 |ll be co|nsidered|
|000004d0| 20 61 6e 20 6f 70 74 69 | 6f 6e 2e 0d 23 20 20 20 | an opti|on..# |
|000004e0| 20 4c 69 6b 65 77 69 73 | 65 2c 20 61 20 64 6f 75 | Likewis|e, a dou|
|000004f0| 62 6c 65 20 6f 63 63 75 | 72 72 65 6e 63 65 20 28 |ble occu|rrence (|
|00000500| 65 2e 67 2e 20 22 2d 2d | 22 29 20 73 69 67 6e 61 |e.g. "--|") signa|
|00000510| 6c 73 20 65 6e 64 20 6f | 66 0d 23 20 20 20 20 74 |ls end o|f.# t|
|00000520| 68 65 20 6f 70 74 69 6f | 6e 73 20 6c 69 73 74 2e |he optio|ns list.|
|00000530| 0d 23 20 20 20 20 54 68 | 65 20 64 65 66 61 75 6c |.# Th|e defaul|
|00000540| 74 20 76 61 6c 75 65 20 | 66 6f 72 20 74 68 65 20 |t value |for the |
|00000550| 73 74 61 72 74 65 72 20 | 69 73 20 22 2d 22 2c 20 |starter |is "-", |
|00000560| 22 2d 2d 22 20 6f 72 20 | 22 2b 22 2e 0d 23 0d 23 |"--" or |"+"..#.#|
|00000570| 20 55 70 6f 6e 20 72 65 | 74 75 72 6e 2c 20 74 68 | Upon re|turn, th|
|00000580| 65 20 6f 70 74 69 6f 6e | 20 76 61 72 69 61 62 6c |e option| variabl|
|00000590| 65 73 2c 20 70 72 65 66 | 69 78 65 64 20 77 69 74 |es, pref|ixed wit|
|000005a0| 68 20 22 6f 70 74 5f 22 | 2c 20 61 72 65 20 64 65 |h "opt_"|, are de|
|000005b0| 66 69 6e 65 64 0d 23 20 | 61 6e 64 20 73 65 74 20 |fined.# |and set |
|000005c0| 74 6f 20 74 68 65 20 72 | 65 73 70 65 63 74 69 76 |to the r|espectiv|
|000005d0| 65 20 6f 70 74 69 6f 6e | 20 61 72 67 75 6d 65 6e |e option| argumen|
|000005e0| 74 73 2c 20 69 66 20 61 | 6e 79 2e 0d 23 20 4f 70 |ts, if a|ny..# Op|
|000005f0| 74 69 6f 6e 73 20 74 68 | 61 74 20 64 6f 20 6e 6f |tions th|at do no|
|00000600| 74 20 74 61 6b 65 20 61 | 6e 20 61 72 67 75 6d 65 |t take a|n argume|
|00000610| 6e 74 20 61 72 65 20 73 | 65 74 20 74 6f 20 31 2e |nt are s|et to 1.|
|00000620| 20 4e 6f 74 65 20 74 68 | 61 74 20 61 6e 0d 23 20 | Note th|at an.# |
|00000630| 6f 70 74 69 6f 6e 20 77 | 69 74 68 20 61 6e 20 6f |option w|ith an o|
|00000640| 70 74 69 6f 6e 61 6c 20 | 61 72 67 75 6d 65 6e 74 |ptional |argument|
|00000650| 20 77 69 6c 6c 20 62 65 | 20 64 65 66 69 6e 65 64 | will be| defined|
|00000660| 2c 20 62 75 74 20 73 65 | 74 20 74 6f 20 27 27 20 |, but se|t to '' |
|00000670| 69 66 0d 23 20 6e 6f 20 | 61 63 74 75 61 6c 20 61 |if.# no |actual a|
|00000680| 72 67 75 6d 65 6e 74 20 | 68 61 73 20 62 65 65 6e |rgument |has been|
|00000690| 20 73 75 70 70 6c 69 65 | 64 2e 0d 23 20 41 20 72 | supplie|d..# A r|
|000006a0| 65 74 75 72 6e 20 73 74 | 61 74 75 73 20 6f 66 20 |eturn st|atus of |
|000006b0| 30 20 28 66 61 6c 73 65 | 29 20 69 6e 64 69 63 61 |0 (false|) indica|
|000006c0| 74 65 73 20 74 68 61 74 | 20 74 68 65 20 66 75 6e |tes that| the fun|
|000006d0| 63 74 69 6f 6e 20 64 65 | 74 65 63 74 65 64 0d 23 |ction de|tected.#|
|000006e0| 20 6f 6e 65 20 6f 72 20 | 6d 6f 72 65 20 65 72 72 | one or |more err|
|000006f0| 6f 72 73 2e 0d 23 0d 23 | 20 53 70 65 63 69 61 6c |ors..#.#| Special|
|00000700| 20 63 61 72 65 20 69 73 | 20 74 61 6b 65 6e 20 74 | care is| taken t|
|00000710| 6f 20 67 69 76 65 20 61 | 20 63 6f 72 72 65 63 74 |o give a| correct|
|00000720| 20 74 72 65 61 74 6d 65 | 6e 74 20 74 6f 20 6f 70 | treatme|nt to op|
|00000730| 74 69 6f 6e 61 6c 20 61 | 72 67 75 6d 65 6e 74 73 |tional a|rguments|
|00000740| 2e 0d 23 0d 23 20 45 2e | 67 2e 20 69 66 20 6f 70 |..#.# E.|g. if op|
|00000750| 74 69 6f 6e 20 22 6f 6e | 65 3a 69 22 20 28 69 2e |tion "on|e:i" (i.|
|00000760| 65 2e 20 74 61 6b 65 73 | 20 61 6e 20 6f 70 74 69 |e. takes| an opti|
|00000770| 6f 6e 61 6c 20 69 6e 74 | 65 67 65 72 20 61 72 67 |onal int|eger arg|
|00000780| 75 6d 65 6e 74 29 2c 0d | 23 20 74 68 65 6e 20 74 |ument),.|# then t|
|00000790| 68 65 20 66 6f 6c 6c 6f | 77 69 6e 67 20 73 69 74 |he follo|wing sit|
|000007a0| 75 61 74 69 6f 6e 73 20 | 61 72 65 20 68 61 6e 64 |uations |are hand|
|000007b0| 6c 65 64 3a 0d 23 0d 23 | 20 20 20 20 2d 6f 6e 65 |led:.#.#| -one|
|000007c0| 20 2d 74 77 6f 09 09 2d | 3e 20 24 6f 70 74 5f 6f | -two..-|> $opt_o|
|000007d0| 6e 65 20 3d 20 27 27 2c | 20 2d 74 77 6f 20 69 73 |ne = '',| -two is|
|000007e0| 20 6e 65 78 74 20 6f 70 | 74 69 6f 6e 0d 23 20 20 | next op|tion.# |
|000007f0| 20 20 2d 6f 6e 65 20 2d | 32 09 09 2d 3e 20 24 6f | -one -|2..-> $o|
|00000800| 70 74 5f 6f 6e 65 20 3d | 20 2d 32 0d 23 0d 23 20 |pt_one =| -2.#.# |
|00000810| 41 6c 73 6f 2c 20 61 73 | 73 75 6d 65 20 22 66 6f |Also, as|sume "fo|
|00000820| 6f 3d 73 22 20 61 6e 64 | 20 22 62 61 72 3a 73 22 |o=s" and| "bar:s"|
|00000830| 20 3a 0d 23 0d 23 20 20 | 20 20 2d 62 61 72 20 2d | :.#.# | -bar -|
|00000840| 78 78 78 09 09 2d 3e 20 | 24 6f 70 74 5f 62 61 72 |xxx..-> |$opt_bar|
|00000850| 20 3d 20 27 27 2c 20 27 | 2d 78 78 78 27 20 69 73 | = '', '|-xxx' is|
|00000860| 20 6e 65 78 74 20 6f 70 | 74 69 6f 6e 0d 23 20 20 | next op|tion.# |
|00000870| 20 20 2d 66 6f 6f 20 2d | 62 61 72 09 09 2d 3e 20 | -foo -|bar..-> |
|00000880| 24 6f 70 74 5f 66 6f 6f | 20 3d 20 27 2d 62 61 72 |$opt_foo| = '-bar|
|00000890| 27 0d 23 20 20 20 20 2d | 66 6f 6f 20 2d 2d 09 09 |'.# -|foo --..|
|000008a0| 2d 3e 20 24 6f 70 74 5f | 66 6f 6f 20 3d 20 27 2d |-> $opt_|foo = '-|
|000008b0| 2d 27 0d 23 0d 23 20 48 | 49 53 54 4f 52 59 20 0d |-'.#.# H|ISTORY .|
|000008c0| 23 20 32 2d 4a 75 6e 2d | 31 39 39 32 09 09 4a 6f |# 2-Jun-|1992..Jo|
|000008d0| 68 61 6e 20 56 72 6f 6d | 61 6e 73 09 0d 23 20 20 |han Vrom|ans..# |
|000008e0| 20 20 44 6f 20 6e 6f 74 | 20 75 73 65 20 2f 2f 6f | Do not| use //o|
|000008f0| 20 74 6f 20 61 6c 6c 6f | 77 20 6d 75 6c 74 69 70 | to allo|w multip|
|00000900| 6c 65 20 4e 47 65 74 4f | 70 74 20 63 61 6c 6c 73 |le NGetO|pt calls|
|00000910| 20 77 69 74 68 20 64 69 | 66 66 65 72 65 6e 74 20 | with di|fferent |
|00000920| 64 65 6c 69 6d 65 74 65 | 72 73 2e 0d 23 20 20 20 |delimete|rs..# |
|00000930| 20 50 72 65 76 65 6e 74 | 20 74 79 70 65 6c 65 73 | Prevent| typeles|
|00000940| 73 20 6f 70 74 69 6f 6e | 20 66 72 6f 6d 20 75 73 |s option| from us|
|00000950| 69 6e 67 20 70 72 65 76 | 69 6f 75 73 20 24 61 72 |ing prev|ious $ar|
|00000960| 72 61 79 20 73 74 61 74 | 65 2e 0d 23 20 20 20 20 |ray stat|e..# |
|00000970| 50 72 65 76 65 6e 74 20 | 65 6d 70 74 79 20 6f 70 |Prevent |empty op|
|00000980| 74 69 6f 6e 20 66 72 6f | 6d 20 62 65 69 6e 67 20 |tion fro|m being |
|00000990| 65 61 74 65 6e 20 61 73 | 20 61 20 28 6e 65 67 61 |eaten as| a (nega|
|000009a0| 74 69 76 65 29 20 6e 75 | 6d 62 65 72 2e 0d 0d 23 |tive) nu|mber...#|
|000009b0| 20 32 35 2d 4d 61 79 2d | 31 39 39 32 09 09 4a 6f | 25-May-|1992..Jo|
|000009c0| 68 61 6e 20 56 72 6f 6d | 61 6e 73 09 0d 23 20 20 |han Vrom|ans..# |
|000009d0| 20 20 41 64 64 20 61 72 | 72 61 79 20 6f 70 74 69 | Add ar|ray opti|
|000009e0| 6f 6e 73 2e 20 22 66 6f | 6f 3d 73 40 22 20 77 69 |ons. "fo|o=s@" wi|
|000009f0| 6c 6c 20 72 65 74 75 72 | 6e 20 61 6e 20 61 72 72 |ll retur|n an arr|
|00000a00| 61 79 20 40 6f 70 74 5f | 66 6f 6f 20 74 68 61 74 |ay @opt_|foo that|
|00000a10| 0d 23 20 20 20 20 63 6f | 6e 74 61 69 6e 73 20 61 |.# co|ntains a|
|00000a20| 6c 6c 20 76 61 6c 75 65 | 73 20 74 68 61 74 20 77 |ll value|s that w|
|00000a30| 65 72 65 20 73 75 70 70 | 6c 69 65 64 2e 20 45 2e |ere supp|lied. E.|
|00000a40| 67 2e 20 22 2d 66 6f 6f | 20 6f 6e 65 20 2d 66 6f |g. "-foo| one -fo|
|00000a50| 6f 20 2d 74 77 6f 22 20 | 77 69 6c 6c 0d 23 20 20 |o -two" |will.# |
|00000a60| 20 20 72 65 74 75 72 6e | 20 40 6f 70 74 5f 66 6f | return| @opt_fo|
|00000a70| 6f 20 3d 20 28 22 6f 6e | 65 22 2c 20 22 2d 74 77 |o = ("on|e", "-tw|
|00000a80| 6f 22 29 3b 0d 23 20 20 | 20 20 43 6f 72 72 65 63 |o");.# | Correc|
|00000a90| 74 20 62 75 67 20 69 6e | 20 68 61 6e 64 6c 69 6e |t bug in| handlin|
|00000aa0| 67 20 6f 70 74 69 6f 6e | 73 20 74 68 61 74 20 61 |g option|s that a|
|00000ab0| 6c 6c 6f 77 20 66 6f 72 | 20 61 20 61 72 67 75 6d |llow for| a argum|
|00000ac0| 65 6e 74 20 77 68 65 6e | 20 66 6f 6c 6c 6f 77 65 |ent when| followe|
|00000ad0| 64 0d 23 20 20 20 20 62 | 79 20 61 6e 6f 74 68 65 |d.# b|y anothe|
|00000ae0| 72 20 6f 70 74 69 6f 6e | 2e 0d 0d 23 20 34 2d 4d |r option|...# 4-M|
|00000af0| 61 79 2d 31 39 39 32 09 | 09 4a 6f 68 61 6e 20 56 |ay-1992.|.Johan V|
|00000b00| 72 6f 6d 61 6e 73 09 0d | 23 20 20 20 20 41 64 64 |romans..|# Add|
|00000b10| 20 24 69 67 6e 6f 72 65 | 63 61 73 65 20 74 6f 20 | $ignore|case to |
|00000b20| 6d 61 74 63 68 20 6f 70 | 74 69 6f 6e 73 20 69 6e |match op|tions in|
|00000b30| 20 65 69 74 68 65 72 20 | 63 61 73 65 2e 0d 23 20 | either |case..# |
|00000b40| 20 20 20 41 6c 6c 6f 77 | 20 27 27 20 6f 70 74 69 | Allow| '' opti|
|00000b50| 6f 6e 2e 0d 0d 23 20 31 | 39 2d 4d 61 72 2d 31 39 |on...# 1|9-Mar-19|
|00000b60| 39 32 09 09 4a 6f 68 61 | 6e 20 56 72 6f 6d 61 6e |92..Joha|n Vroman|
|00000b70| 73 09 0d 23 20 20 20 20 | 41 6c 6c 6f 77 20 72 65 |s..# |Allow re|
|00000b80| 71 75 69 72 65 20 66 72 | 6f 6d 20 70 61 63 6b 61 |quire fr|om packa|
|00000b90| 67 65 73 2e 0d 23 20 20 | 20 20 4e 47 65 74 4f 70 |ges..# | NGetOp|
|00000ba0| 74 20 69 73 20 6e 6f 77 | 20 64 65 66 69 6e 65 64 |t is now| defined|
|00000bb0| 20 69 6e 20 74 68 65 20 | 70 61 63 6b 61 67 65 20 | in the |package |
|00000bc0| 74 68 61 74 20 72 65 71 | 75 69 72 65 73 20 69 74 |that req|uires it|
|00000bd0| 2e 0d 23 20 20 20 20 40 | 41 52 47 56 20 61 6e 64 |..# @|ARGV and|
|00000be0| 20 24 6f 70 74 5f 2e 2e | 2e 20 61 72 65 20 74 61 | $opt_..|. are ta|
|00000bf0| 6b 65 6e 20 66 72 6f 6d | 20 74 68 65 20 70 61 63 |ken from| the pac|
|00000c00| 6b 61 67 65 20 74 68 61 | 74 20 63 61 6c 6c 73 20 |kage tha|t calls |
|00000c10| 69 74 2e 0d 23 20 20 20 | 20 55 73 65 20 73 74 61 |it..# | Use sta|
|00000c20| 6e 64 61 72 64 20 28 3f | 29 20 6f 70 74 69 6f 6e |ndard (?|) option|
|00000c30| 20 70 72 65 66 69 78 65 | 73 3a 20 2d 2c 20 2d 2d | prefixe|s: -, --|
|00000c40| 20 61 6e 64 20 2b 2e 0d | 0d 23 20 32 30 2d 53 65 | and +..|.# 20-Se|
|00000c50| 70 2d 31 39 39 30 09 09 | 4a 6f 68 61 6e 20 56 72 |p-1990..|Johan Vr|
|00000c60| 6f 6d 61 6e 73 09 0d 23 | 20 20 20 20 53 65 74 20 |omans..#| Set |
|00000c70| 6f 70 74 69 6f 6e 73 20 | 77 2f 6f 20 61 72 67 75 |options |w/o argu|
|00000c80| 6d 65 6e 74 20 74 6f 20 | 31 2e 0d 23 20 20 20 20 |ment to |1..# |
|00000c90| 43 6f 72 72 65 63 74 20 | 74 68 65 20 64 72 65 61 |Correct |the drea|
|00000ca0| 64 66 75 6c 20 73 65 6d | 69 63 6f 6c 6f 6e 2f 72 |dful sem|icolon/r|
|00000cb0| 65 71 75 69 72 65 20 62 | 75 67 2e 0d 0d 0d 7b 20 |equire b|ug....{ |
|00000cc0| 20 20 70 61 63 6b 61 67 | 65 20 6e 65 77 67 65 74 | packag|e newget|
|00000cd0| 6f 70 74 3b 0d 20 20 20 | 20 24 64 65 62 75 67 20 |opt;. | $debug |
|00000ce0| 3d 20 30 3b 09 09 09 23 | 20 66 6f 72 20 64 65 62 |= 0;...#| for deb|
|00000cf0| 75 67 67 69 6e 67 0d 20 | 20 20 20 24 69 67 6e 6f |ugging. | $igno|
|00000d00| 72 65 63 61 73 65 20 3d | 20 31 3b 09 09 23 20 69 |recase =| 1;..# i|
|00000d10| 67 6e 6f 72 65 20 63 61 | 73 65 20 77 68 65 6e 20 |gnore ca|se when |
|00000d20| 6d 61 74 63 68 69 6e 67 | 20 6f 70 74 69 6f 6e 73 |matching| options|
|00000d30| 0d 7d 0d 0d 73 75 62 20 | 4e 47 65 74 4f 70 74 20 |.}..sub |NGetOpt |
|00000d40| 7b 0d 0d 20 20 20 20 40 | 6e 65 77 67 65 74 6f 70 |{.. @|newgetop|
|00000d50| 74 27 6f 70 74 69 6f 6e | 6c 69 73 74 20 3d 20 40 |t'option|list = @|
|00000d60| 5f 3b 0d 20 20 20 20 2a | 6e 65 77 67 65 74 6f 70 |_;. *|newgetop|
|00000d70| 74 27 41 52 47 56 20 3d | 20 2a 41 52 47 56 3b 0d |t'ARGV =| *ARGV;.|
|00000d80| 0d 20 20 20 20 70 61 63 | 6b 61 67 65 20 6e 65 77 |. pac|kage new|
|00000d90| 67 65 74 6f 70 74 3b 0d | 0d 20 20 20 20 6c 6f 63 |getopt;.|. loc|
|00000da0| 61 6c 20 28 24 5b 29 20 | 3d 20 30 3b 0d 20 20 20 |al ($[) |= 0;. |
|00000db0| 20 6c 6f 63 61 6c 20 28 | 24 67 65 6e 70 72 65 66 | local (|$genpref|
|00000dc0| 69 78 29 20 3d 20 22 28 | 2d 2d 7c 2d 7c 5c 5c 2b |ix) = "(|--|-|\\+|
|00000dd0| 29 22 3b 0d 20 20 20 20 | 6c 6f 63 61 6c 20 28 24 |)";. |local ($|
|00000de0| 61 72 67 65 6e 64 29 20 | 3d 20 22 2d 2d 22 3b 0d |argend) |= "--";.|
|00000df0| 20 20 20 20 6c 6f 63 61 | 6c 20 28 24 65 72 72 6f | loca|l ($erro|
|00000e00| 72 29 20 3d 20 30 3b 0d | 20 20 20 20 6c 6f 63 61 |r) = 0;.| loca|
|00000e10| 6c 20 28 24 6f 70 74 2c | 20 24 6f 70 74 78 2c 20 |l ($opt,| $optx, |
|00000e20| 24 61 72 67 2c 20 24 74 | 79 70 65 2c 20 24 6d 61 |$arg, $t|ype, $ma|
|00000e30| 6e 64 2c 20 25 6f 70 63 | 74 6c 29 3b 0d 20 20 20 |nd, %opc|tl);. |
|00000e40| 20 6c 6f 63 61 6c 20 28 | 24 70 6b 67 29 20 3d 20 | local (|$pkg) = |
|00000e50| 28 63 61 6c 6c 65 72 29 | 5b 30 5d 3b 0d 0d 20 20 |(caller)|[0];.. |
|00000e60| 20 20 70 72 69 6e 74 20 | 53 54 44 45 52 52 20 22 | print |STDERR "|
|00000e70| 4e 47 65 74 4f 70 74 20 | 31 2e 31 33 20 2d 2d 20 |NGetOpt |1.13 -- |
|00000e80| 63 61 6c 6c 65 64 20 66 | 72 6f 6d 20 24 70 6b 67 |called f|rom $pkg|
|00000e90| 5c 6e 22 20 69 66 20 24 | 64 65 62 75 67 3b 0d 0d |\n" if $|debug;..|
|00000ea0| 20 20 20 20 23 20 53 65 | 65 20 69 66 20 74 68 65 | # Se|e if the|
|00000eb0| 20 66 69 72 73 74 20 65 | 6c 65 6d 65 6e 74 20 6f | first e|lement o|
|00000ec0| 66 20 74 68 65 20 6f 70 | 74 69 6f 6e 6c 69 73 74 |f the op|tionlist|
|00000ed0| 20 63 6f 6e 74 61 69 6e | 73 20 6f 70 74 69 6f 6e | contain|s option|
|00000ee0| 0d 20 20 20 20 23 20 73 | 74 61 72 74 65 72 20 63 |. # s|tarter c|
|00000ef0| 68 61 72 61 63 74 65 72 | 73 2e 0d 20 20 20 20 69 |haracter|s.. i|
|00000f00| 66 20 28 20 24 6f 70 74 | 69 6f 6e 6c 69 73 74 5b |f ( $opt|ionlist[|
|00000f10| 30 5d 20 3d 7e 20 2f 5e | 5c 57 2b 24 2f 20 29 20 |0] =~ /^|\W+$/ ) |
|00000f20| 7b 0d 09 24 67 65 6e 70 | 72 65 66 69 78 20 3d 20 |{..$genp|refix = |
|00000f30| 73 68 69 66 74 20 28 40 | 6f 70 74 69 6f 6e 6c 69 |shift (@|optionli|
|00000f40| 73 74 29 3b 0d 09 23 20 | 54 75 72 6e 20 69 6e 74 |st);..# |Turn int|
|00000f50| 6f 20 72 65 67 65 78 70 | 2e 0d 09 24 67 65 6e 70 |o regexp|...$genp|
|00000f60| 72 65 66 69 78 20 3d 7e | 20 73 2f 28 5c 57 29 2f |refix =~| s/(\W)/|
|00000f70| 5c 5c 5c 31 2f 67 3b 0d | 09 24 67 65 6e 70 72 65 |\\\1/g;.|.$genpre|
|00000f80| 66 69 78 20 3d 20 22 5b | 22 20 2e 20 24 67 65 6e |fix = "[|" . $gen|
|00000f90| 70 72 65 66 69 78 20 2e | 20 22 5d 22 3b 0d 09 75 |prefix .| "]";..u|
|00000fa0| 6e 64 65 66 20 24 61 72 | 67 65 6e 64 3b 0d 20 20 |ndef $ar|gend;. |
|00000fb0| 20 20 7d 0d 0d 20 20 20 | 20 23 20 56 65 72 69 66 | }.. | # Verif|
|00000fc0| 79 20 63 6f 72 72 65 63 | 74 6e 65 73 73 20 6f 66 |y correc|tness of|
|00000fd0| 20 6f 70 74 69 6f 6e 6c | 69 73 74 2e 0d 20 20 20 | optionl|ist.. |
|00000fe0| 20 25 6f 70 63 74 6c 20 | 3d 20 28 29 3b 0d 20 20 | %opctl |= ();. |
|00000ff0| 20 20 66 6f 72 65 61 63 | 68 20 24 6f 70 74 20 28 | foreac|h $opt (|
|00001000| 20 40 6f 70 74 69 6f 6e | 6c 69 73 74 20 29 20 7b | @option|list ) {|
|00001010| 0d 09 24 6f 70 74 20 3d | 7e 20 74 72 2f 41 2d 5a |..$opt =|~ tr/A-Z|
|00001020| 2f 61 2d 7a 2f 20 69 66 | 20 24 69 67 6e 6f 72 65 |/a-z/ if| $ignore|
|00001030| 63 61 73 65 3b 0d 09 69 | 66 20 28 20 24 6f 70 74 |case;..i|f ( $opt|
|00001040| 20 21 7e 20 2f 5e 28 5c | 77 2a 29 28 5b 3d 3a 5d | !~ /^(\|w*)([=:]|
|00001050| 5b 69 6e 66 73 65 5d 40 | 3f 29 3f 24 2f 20 29 20 |[infse]@|?)?$/ ) |
|00001060| 7b 0d 09 20 20 20 20 70 | 72 69 6e 74 20 53 54 44 |{.. p|rint STD|
|00001070| 45 52 52 20 28 22 45 72 | 72 6f 72 20 69 6e 20 6f |ERR ("Er|ror in o|
|00001080| 70 74 69 6f 6e 20 73 70 | 65 63 3a 20 5c 22 22 2c |ption sp|ec: \"",|
|00001090| 20 24 6f 70 74 2c 20 22 | 5c 22 5c 6e 22 29 3b 0d | $opt, "|\"\n");.|
|000010a0| 09 20 20 20 20 24 65 72 | 72 6f 72 2b 2b 3b 0d 09 |. $er|ror++;..|
|000010b0| 20 20 20 20 6e 65 78 74 | 3b 0d 09 7d 0d 09 24 6f | next|;..}..$o|
|000010c0| 70 63 74 6c 7b 24 31 7d | 20 3d 20 64 65 66 69 6e |pctl{$1}| = defin|
|000010d0| 65 64 20 24 32 20 3f 20 | 24 32 20 3a 20 22 22 3b |ed $2 ? |$2 : "";|
|000010e0| 0d 20 20 20 20 7d 0d 0d | 20 20 20 20 72 65 74 75 |. }..| retu|
|000010f0| 72 6e 20 30 20 69 66 20 | 24 65 72 72 6f 72 3b 0d |rn 0 if |$error;.|
|00001100| 0d 20 20 20 20 69 66 20 | 28 20 24 64 65 62 75 67 |. if |( $debug|
|00001110| 20 29 20 7b 0d 09 6c 6f | 63 61 6c 20 28 24 61 72 | ) {..lo|cal ($ar|
|00001120| 72 6f 77 2c 20 24 6b 2c | 20 24 76 29 3b 0d 09 24 |row, $k,| $v);..$|
|00001130| 61 72 72 6f 77 20 3d 20 | 22 3d 3e 20 22 3b 0d 09 |arrow = |"=> ";..|
|00001140| 77 68 69 6c 65 20 28 20 | 28 24 6b 2c 24 76 29 20 |while ( |($k,$v) |
|00001150| 3d 20 65 61 63 68 28 25 | 6f 70 63 74 6c 29 20 29 |= each(%|opctl) )|
|00001160| 20 7b 0d 09 20 20 20 20 | 70 72 69 6e 74 20 53 54 | {.. |print ST|
|00001170| 44 45 52 52 20 28 24 61 | 72 72 6f 77 2c 20 22 5c |DERR ($a|rrow, "\|
|00001180| 24 6f 70 63 74 6c 7b 5c | 22 24 6b 5c 22 7d 20 3d |$opctl{\|"$k\"} =|
|00001190| 20 5c 22 24 76 5c 22 5c | 6e 22 29 3b 0d 09 20 20 | \"$v\"\|n");.. |
|000011a0| 20 20 24 61 72 72 6f 77 | 20 3d 20 22 20 20 20 22 | $arrow| = " "|
|000011b0| 3b 0d 09 7d 0d 20 20 20 | 20 7d 0d 0d 20 20 20 20 |;..}. | }.. |
|000011c0| 23 20 50 72 6f 63 65 73 | 73 20 61 72 67 75 6d 65 |# Proces|s argume|
|000011d0| 6e 74 20 6c 69 73 74 0d | 0d 20 20 20 20 77 68 69 |nt list.|. whi|
|000011e0| 6c 65 20 28 20 24 23 41 | 52 47 56 20 3e 3d 20 30 |le ( $#A|RGV >= 0|
|000011f0| 20 29 20 7b 0d 0d 09 23 | 20 3e 3e 3e 20 53 65 65 | ) {...#| >>> See|
|00001200| 20 61 6c 73 6f 20 74 68 | 65 20 63 6f 6e 74 69 6e | also th|e contin|
|00001210| 75 65 20 62 6c 6f 63 6b | 20 3c 3c 3c 0d 0d 09 23 |ue block| <<<...#|
|00001220| 20 47 65 74 20 6e 65 78 | 74 20 61 72 67 75 6d 65 | Get nex|t argume|
|00001230| 6e 74 0d 09 24 6f 70 74 | 20 3d 20 73 68 69 66 74 |nt..$opt| = shift|
|00001240| 20 28 40 41 52 47 56 29 | 3b 0d 09 70 72 69 6e 74 | (@ARGV)|;..print|
|00001250| 20 53 54 44 45 52 52 20 | 28 22 3d 3e 20 6f 70 74 | STDERR |("=> opt|
|00001260| 69 6f 6e 20 5c 22 22 2c | 20 24 6f 70 74 2c 20 22 |ion \"",| $opt, "|
|00001270| 5c 22 5c 6e 22 29 20 69 | 66 20 24 64 65 62 75 67 |\"\n") i|f $debug|
|00001280| 3b 0d 09 24 61 72 67 20 | 3d 20 75 6e 64 65 66 3b |;..$arg |= undef;|
|00001290| 0d 0d 09 23 20 43 68 65 | 63 6b 20 66 6f 72 20 65 |...# Che|ck for e|
|000012a0| 78 68 61 75 73 74 65 64 | 20 6c 69 73 74 2e 0d 09 |xhausted| list...|
|000012b0| 69 66 20 28 20 24 6f 70 | 74 20 3d 7e 20 2f 5e 24 |if ( $op|t =~ /^$|
|000012c0| 67 65 6e 70 72 65 66 69 | 78 2f 20 29 20 7b 0d 09 |genprefi|x/ ) {..|
|000012d0| 20 20 20 20 23 20 44 6f | 75 62 6c 65 20 6f 63 63 | # Do|uble occ|
|000012e0| 75 72 72 65 6e 63 65 20 | 69 73 20 74 65 72 6d 69 |urrence |is termi|
|000012f0| 6e 61 74 6f 72 0d 09 20 | 20 20 20 72 65 74 75 72 |nator.. | retur|
|00001300| 6e 20 28 24 65 72 72 6f | 72 20 3d 3d 20 30 29 20 |n ($erro|r == 0) |
|00001310| 0d 09 09 69 66 20 28 24 | 6f 70 74 20 65 71 20 22 |...if ($|opt eq "|
|00001320| 24 2b 24 2b 22 29 20 7c | 7c 20 28 28 64 65 66 69 |$+$+") ||| ((defi|
|00001330| 6e 65 64 20 24 61 72 67 | 65 6e 64 29 20 26 26 20 |ned $arg|end) && |
|00001340| 24 6f 70 74 20 65 71 20 | 24 61 72 67 65 6e 64 29 |$opt eq |$argend)|
|00001350| 3b 0d 09 20 20 20 20 24 | 6f 70 74 20 3d 20 24 27 |;.. $|opt = $'|
|00001360| 3b 09 09 23 20 6f 70 74 | 69 6f 6e 20 6e 61 6d 65 |;..# opt|ion name|
|00001370| 20 28 77 2f 6f 20 70 72 | 65 66 69 78 29 0d 09 7d | (w/o pr|efix)..}|
|00001380| 0d 09 65 6c 73 65 20 7b | 0d 09 20 20 20 20 23 20 |..else {|.. # |
|00001390| 41 70 70 61 72 65 6e 74 | 6c 79 20 6e 6f 74 20 61 |Apparent|ly not a|
|000013a0| 6e 20 6f 70 74 69 6f 6e | 20 2d 20 70 75 73 68 20 |n option| - push |
|000013b0| 62 61 63 6b 20 61 6e 64 | 20 65 78 69 74 2e 0d 09 |back and| exit...|
|000013c0| 20 20 20 20 75 6e 73 68 | 69 66 74 20 28 40 41 52 | unsh|ift (@AR|
|000013d0| 47 56 2c 20 24 6f 70 74 | 29 3b 0d 09 20 20 20 20 |GV, $opt|);.. |
|000013e0| 72 65 74 75 72 6e 20 28 | 24 65 72 72 6f 72 20 3d |return (|$error =|
|000013f0| 3d 20 30 29 3b 0d 09 7d | 0d 0d 09 23 20 4c 6f 6f |= 0);..}|...# Loo|
|00001400| 6b 20 69 74 20 75 70 2e | 0d 09 24 6f 70 74 20 3d |k it up.|..$opt =|
|00001410| 7e 20 74 72 2f 41 2d 5a | 2f 61 2d 7a 2f 20 69 66 |~ tr/A-Z|/a-z/ if|
|00001420| 20 24 69 67 6e 6f 72 65 | 63 61 73 65 3b 0d 09 75 | $ignore|case;..u|
|00001430| 6e 6c 65 73 73 20 20 28 | 20 64 65 66 69 6e 65 64 |nless (| defined|
|00001440| 20 28 20 24 74 79 70 65 | 20 3d 20 24 6f 70 63 74 | ( $type| = $opct|
|00001450| 6c 7b 24 6f 70 74 7d 20 | 29 20 29 20 7b 0d 09 20 |l{$opt} |) ) {.. |
|00001460| 20 20 20 70 72 69 6e 74 | 20 53 54 44 45 52 52 20 | print| STDERR |
|00001470| 28 22 55 6e 6b 6e 6f 77 | 6e 20 6f 70 74 69 6f 6e |("Unknow|n option|
|00001480| 3a 20 22 2c 20 24 6f 70 | 74 2c 20 22 5c 6e 22 29 |: ", $op|t, "\n")|
|00001490| 3b 0d 09 20 20 20 20 24 | 65 72 72 6f 72 2b 2b 3b |;.. $|error++;|
|000014a0| 0d 09 20 20 20 20 6e 65 | 78 74 3b 0d 09 7d 0d 0d |.. ne|xt;..}..|
|000014b0| 09 23 20 44 65 74 65 72 | 6d 69 6e 65 20 61 72 67 |.# Deter|mine arg|
|000014c0| 75 6d 65 6e 74 20 73 74 | 61 74 75 73 2e 0d 09 70 |ument st|atus...p|
|000014d0| 72 69 6e 74 20 53 54 44 | 45 52 52 20 28 22 3d 3e |rint STD|ERR ("=>|
|000014e0| 20 66 6f 75 6e 64 20 5c | 22 24 74 79 70 65 5c 22 | found \|"$type\"|
|000014f0| 20 66 6f 72 20 22 2c 20 | 24 6f 70 74 2c 20 22 5c | for ", |$opt, "\|
|00001500| 6e 22 29 20 69 66 20 24 | 64 65 62 75 67 3b 0d 0d |n") if $|debug;..|
|00001510| 09 23 20 49 66 20 69 74 | 20 69 73 20 61 6e 20 6f |.# If it| is an o|
|00001520| 70 74 69 6f 6e 20 77 2f | 6f 20 61 72 67 75 6d 65 |ption w/|o argume|
|00001530| 6e 74 2c 20 77 65 27 72 | 65 20 61 6c 6d 6f 73 74 |nt, we'r|e almost|
|00001540| 20 66 69 6e 69 73 68 65 | 64 20 77 69 74 68 20 69 | finishe|d with i|
|00001550| 74 2e 0d 09 69 66 20 28 | 20 24 74 79 70 65 20 65 |t...if (| $type e|
|00001560| 71 20 22 22 20 29 20 7b | 0d 09 20 20 20 20 24 61 |q "" ) {|.. $a|
|00001570| 72 67 20 3d 20 31 3b 09 | 09 23 20 73 75 70 70 6c |rg = 1;.|.# suppl|
|00001580| 79 20 65 78 70 6c 69 63 | 69 74 20 76 61 6c 75 65 |y explic|it value|
|00001590| 0d 09 20 20 20 20 24 61 | 72 72 61 79 20 3d 20 30 |.. $a|rray = 0|
|000015a0| 3b 0d 09 20 20 20 20 6e | 65 78 74 3b 0d 09 7d 0d |;.. n|ext;..}.|
|000015b0| 0d 09 23 20 47 65 74 20 | 6d 61 6e 64 61 74 6f 72 |..# Get |mandator|
|000015c0| 79 20 73 74 61 74 75 73 | 20 61 6e 64 20 74 79 70 |y status| and typ|
|000015d0| 65 20 69 6e 66 6f 2e 0d | 09 28 24 6d 61 6e 64 2c |e info..|.($mand,|
|000015e0| 20 24 74 79 70 65 2c 20 | 24 61 72 72 61 79 29 20 | $type, |$array) |
|000015f0| 3d 20 24 74 79 70 65 20 | 3d 7e 20 2f 5e 28 2e 29 |= $type |=~ /^(.)|
|00001600| 28 2e 29 28 40 3f 29 24 | 2f 3b 0d 0d 09 23 20 43 |(.)(@?)$|/;...# C|
|00001610| 68 65 63 6b 20 69 66 20 | 74 68 65 20 61 72 67 75 |heck if |the argu|
|00001620| 6d 65 6e 74 20 6c 69 73 | 74 20 69 73 20 65 78 68 |ment lis|t is exh|
|00001630| 61 75 73 74 65 64 2e 0d | 09 69 66 20 28 20 24 23 |austed..|.if ( $#|
|00001640| 41 52 47 56 20 3c 20 30 | 20 29 20 7b 0d 0d 09 20 |ARGV < 0| ) {... |
|00001650| 20 20 20 23 20 43 6f 6d | 70 6c 61 69 6e 20 69 66 | # Com|plain if|
|00001660| 20 74 68 69 73 20 6f 70 | 74 69 6f 6e 20 6e 65 65 | this op|tion nee|
|00001670| 64 73 20 61 6e 20 61 72 | 67 75 6d 65 6e 74 2e 0d |ds an ar|gument..|
|00001680| 09 20 20 20 20 69 66 20 | 28 20 24 6d 61 6e 64 20 |. if |( $mand |
|00001690| 65 71 20 22 3d 22 20 29 | 20 7b 0d 09 09 70 72 69 |eq "=" )| {...pri|
|000016a0| 6e 74 20 53 54 44 45 52 | 52 20 28 22 4f 70 74 69 |nt STDER|R ("Opti|
|000016b0| 6f 6e 20 22 2c 20 24 6f | 70 74 2c 20 22 20 72 65 |on ", $o|pt, " re|
|000016c0| 71 75 69 72 65 73 20 61 | 6e 20 61 72 67 75 6d 65 |quires a|n argume|
|000016d0| 6e 74 5c 6e 22 29 3b 0d | 09 09 24 65 72 72 6f 72 |nt\n");.|..$error|
|000016e0| 2b 2b 3b 0d 09 20 20 20 | 20 7d 0d 09 20 20 20 20 |++;.. | }.. |
|000016f0| 69 66 20 28 20 24 6d 61 | 6e 64 20 65 71 20 22 3a |if ( $ma|nd eq ":|
|00001700| 22 20 29 20 7b 0d 09 09 | 24 61 72 67 20 3d 20 24 |" ) {...|$arg = $|
|00001710| 74 79 70 65 20 65 71 20 | 22 73 22 20 3f 20 22 22 |type eq |"s" ? ""|
|00001720| 20 3a 20 30 3b 0d 09 20 | 20 20 20 7d 0d 09 20 20 | : 0;.. | }.. |
|00001730| 20 20 6e 65 78 74 3b 0d | 09 7d 0d 0d 09 23 20 47 | next;.|.}...# G|
|00001740| 65 74 20 28 70 6f 73 73 | 69 62 6c 79 20 6f 70 74 |et (poss|ibly opt|
|00001750| 69 6f 6e 61 6c 29 20 61 | 72 67 75 6d 65 6e 74 2e |ional) a|rgument.|
|00001760| 0d 09 24 61 72 67 20 3d | 20 73 68 69 66 74 20 28 |..$arg =| shift (|
|00001770| 40 41 52 47 56 29 3b 0d | 0d 09 23 20 43 68 65 63 |@ARGV);.|..# Chec|
|00001780| 6b 20 69 66 20 69 74 20 | 69 73 20 61 20 76 61 6c |k if it |is a val|
|00001790| 69 64 20 61 72 67 75 6d | 65 6e 74 2e 20 41 20 6d |id argum|ent. A m|
|000017a0| 61 6e 64 61 74 6f 72 79 | 20 73 74 72 69 6e 67 20 |andatory| string |
|000017b0| 74 61 6b 65 73 0d 09 23 | 20 61 6e 79 74 68 69 6e |takes..#| anythin|
|000017c0| 67 2e 20 0d 09 69 66 20 | 28 20 22 24 6d 61 6e 64 |g. ..if |( "$mand|
|000017d0| 24 74 79 70 65 22 20 6e | 65 20 22 3d 73 22 20 26 |$type" n|e "=s" &|
|000017e0| 26 20 24 61 72 67 20 3d | 7e 20 2f 5e 24 67 65 6e |& $arg =|~ /^$gen|
|000017f0| 70 72 65 66 69 78 2f 20 | 29 20 7b 0d 0d 09 20 20 |prefix/ |) {... |
|00001800| 20 20 23 20 43 68 65 63 | 6b 20 66 6f 72 20 6f 70 | # Chec|k for op|
|00001810| 74 69 6f 6e 20 6c 69 73 | 74 20 74 65 72 6d 69 6e |tion lis|t termin|
|00001820| 61 74 6f 72 2e 0d 09 20 | 20 20 20 69 66 20 28 20 |ator... | if ( |
|00001830| 24 61 72 67 20 65 71 20 | 22 24 2b 24 2b 22 20 7c |$arg eq |"$+$+" ||
|00001840| 7c 20 0d 09 09 20 28 28 | 64 65 66 69 6e 65 64 20 || ... ((|defined |
|00001850| 24 61 72 67 65 6e 64 29 | 20 26 26 20 24 61 72 67 |$argend)| && $arg|
|00001860| 20 65 71 20 24 61 72 67 | 65 6e 64 29 29 20 7b 0d | eq $arg|end)) {.|
|00001870| 09 09 23 20 50 75 73 68 | 20 62 61 63 6b 20 73 6f |..# Push| back so|
|00001880| 20 74 68 65 20 6f 75 74 | 65 72 20 6c 6f 6f 70 20 | the out|er loop |
|00001890| 77 69 6c 6c 20 74 65 72 | 6d 69 6e 61 74 65 2e 0d |will ter|minate..|
|000018a0| 09 09 75 6e 73 68 69 66 | 74 20 28 40 41 52 47 56 |..unshif|t (@ARGV|
|000018b0| 2c 20 24 61 72 67 29 3b | 0d 09 09 23 20 43 6f 6d |, $arg);|...# Com|
|000018c0| 70 6c 61 69 6e 20 69 66 | 20 61 6e 20 61 72 67 75 |plain if| an argu|
|000018d0| 6d 65 6e 74 20 69 73 20 | 72 65 71 75 69 72 65 64 |ment is |required|
|000018e0| 2e 0d 09 09 69 66 20 28 | 24 6d 61 6e 64 20 65 71 |....if (|$mand eq|
|000018f0| 20 22 3d 22 29 20 7b 0d | 09 09 20 20 20 20 70 72 | "=") {.|.. pr|
|00001900| 69 6e 74 20 53 54 44 45 | 52 52 20 28 22 4f 70 74 |int STDE|RR ("Opt|
|00001910| 69 6f 6e 20 22 2c 20 24 | 6f 70 74 2c 20 22 20 72 |ion ", $|opt, " r|
|00001920| 65 71 75 69 72 65 73 20 | 61 6e 20 61 72 67 75 6d |equires |an argum|
|00001930| 65 6e 74 5c 6e 22 29 3b | 0d 09 09 20 20 20 20 24 |ent\n");|... $|
|00001940| 65 72 72 6f 72 2b 2b 3b | 0d 09 09 20 20 20 20 75 |error++;|... u|
|00001950| 6e 64 65 66 20 24 61 72 | 67 3b 09 23 20 64 6f 6e |ndef $ar|g;.# don|
|00001960| 27 74 20 61 73 73 69 67 | 6e 20 69 74 0d 09 09 7d |'t assig|n it...}|
|00001970| 0d 09 09 65 6c 73 65 20 | 7b 0d 09 09 20 20 20 20 |...else |{... |
|00001980| 23 20 53 75 70 70 6c 79 | 20 65 6d 70 74 79 20 76 |# Supply| empty v|
|00001990| 61 6c 75 65 2e 0d 09 09 | 20 20 20 20 24 61 72 67 |alue....| $arg|
|000019a0| 20 3d 20 24 74 79 70 65 | 20 65 71 20 22 73 22 20 | = $type| eq "s" |
|000019b0| 3f 20 22 22 20 3a 20 30 | 3b 0d 09 09 7d 0d 09 09 |? "" : 0|;...}...|
|000019c0| 6e 65 78 74 3b 0d 09 20 | 20 20 20 7d 0d 0d 09 20 |next;.. | }... |
|000019d0| 20 20 20 23 20 4d 61 79 | 62 65 20 74 68 65 20 6f | # May|be the o|
|000019e0| 70 74 69 6f 6e 61 6c 20 | 61 72 67 75 6d 65 6e 74 |ptional |argument|
|000019f0| 20 69 73 20 74 68 65 20 | 6e 65 78 74 20 6f 70 74 | is the |next opt|
|00001a00| 69 6f 6e 3f 0d 09 20 20 | 20 20 69 66 20 28 20 24 |ion?.. | if ( $|
|00001a10| 6d 61 6e 64 20 65 71 20 | 22 3a 22 20 26 26 20 28 |mand eq |":" && (|
|00001a20| 24 27 20 65 71 20 22 22 | 20 7c 7c 20 24 27 20 3d |$' eq ""| || $' =|
|00001a30| 7e 20 2f 5b 61 2d 7a 41 | 2d 5a 5f 5d 2f 29 20 29 |~ /[a-zA|-Z_]/) )|
|00001a40| 20 7b 0d 09 09 23 20 59 | 65 70 2e 20 50 75 73 68 | {...# Y|ep. Push|
|00001a50| 20 62 61 63 6b 2e 0d 09 | 09 75 6e 73 68 69 66 74 | back...|.unshift|
|00001a60| 20 28 40 41 52 47 56 2c | 20 24 61 72 67 29 3b 0d | (@ARGV,| $arg);.|
|00001a70| 09 09 24 61 72 67 20 3d | 20 24 74 79 70 65 20 65 |..$arg =| $type e|
|00001a80| 71 20 22 73 22 20 3f 20 | 22 22 20 3a 20 30 3b 0d |q "s" ? |"" : 0;.|
|00001a90| 09 09 6e 65 78 74 3b 0d | 09 20 20 20 20 7d 0d 09 |..next;.|. }..|
|00001aa0| 7d 0d 0d 09 69 66 20 28 | 20 24 74 79 70 65 20 65 |}...if (| $type e|
|00001ab0| 71 20 22 6e 22 20 7c 7c | 20 24 74 79 70 65 20 65 |q "n" ||| $type e|
|00001ac0| 71 20 22 69 22 20 29 20 | 7b 20 23 20 6e 75 6d 65 |q "i" ) |{ # nume|
|00001ad0| 72 69 63 2f 69 6e 74 65 | 67 65 72 0d 09 20 20 20 |ric/inte|ger.. |
|00001ae0| 20 69 66 20 28 20 24 61 | 72 67 20 21 7e 20 2f 5e | if ( $a|rg !~ /^|
|00001af0| 2d 3f 5b 30 2d 39 5d 2b | 24 2f 20 29 20 7b 0d 09 |-?[0-9]+|$/ ) {..|
|00001b00| 09 70 72 69 6e 74 20 53 | 54 44 45 52 52 20 28 22 |.print S|TDERR ("|
|00001b10| 56 61 6c 75 65 20 5c 22 | 22 2c 20 24 61 72 67 2c |Value \"|", $arg,|
|00001b20| 20 22 5c 22 20 69 6e 76 | 61 6c 69 64 20 66 6f 72 | "\" inv|alid for|
|00001b30| 20 6f 70 74 69 6f 6e 20 | 22 2c 0d 09 09 09 20 20 | option |",.... |
|00001b40| 20 20 20 20 24 6f 70 74 | 2c 20 22 20 28 6e 75 6d | $opt|, " (num|
|00001b50| 62 65 72 20 65 78 70 65 | 63 74 65 64 29 5c 6e 22 |ber expe|cted)\n"|
|00001b60| 29 3b 0d 09 09 24 65 72 | 72 6f 72 2b 2b 3b 0d 09 |);...$er|ror++;..|
|00001b70| 09 75 6e 64 65 66 20 24 | 61 72 67 3b 09 23 20 64 |.undef $|arg;.# d|
|00001b80| 6f 6e 27 74 20 61 73 73 | 69 67 6e 20 69 74 0d 09 |on't ass|ign it..|
|00001b90| 20 20 20 20 7d 0d 09 20 | 20 20 20 6e 65 78 74 3b | }.. | next;|
|00001ba0| 0d 09 7d 0d 0d 09 69 66 | 20 28 20 24 74 79 70 65 |..}...if| ( $type|
|00001bb0| 20 65 71 20 22 66 22 20 | 29 20 7b 20 23 20 66 69 | eq "f" |) { # fi|
|00001bc0| 78 65 64 20 72 65 61 6c | 20 6e 75 6d 62 65 72 2c |xed real| number,|
|00001bd0| 20 69 6e 74 20 69 73 20 | 61 6c 73 6f 20 6f 6b 0d | int is |also ok.|
|00001be0| 09 20 20 20 20 69 66 20 | 28 20 24 61 72 67 20 21 |. if |( $arg !|
|00001bf0| 7e 20 2f 5e 2d 3f 5b 30 | 2d 39 2e 5d 2b 24 2f 20 |~ /^-?[0|-9.]+$/ |
|00001c00| 29 20 7b 0d 09 09 70 72 | 69 6e 74 20 53 54 44 45 |) {...pr|int STDE|
|00001c10| 52 52 20 28 22 56 61 6c | 75 65 20 5c 22 22 2c 20 |RR ("Val|ue \"", |
|00001c20| 24 61 72 67 2c 20 22 5c | 22 20 69 6e 76 61 6c 69 |$arg, "\|" invali|
|00001c30| 64 20 66 6f 72 20 6f 70 | 74 69 6f 6e 20 22 2c 0d |d for op|tion ",.|
|00001c40| 09 09 09 20 20 20 20 20 | 20 24 6f 70 74 2c 20 22 |... | $opt, "|
|00001c50| 20 28 72 65 61 6c 20 6e | 75 6d 62 65 72 20 65 78 | (real n|umber ex|
|00001c60| 70 65 63 74 65 64 29 5c | 6e 22 29 3b 0d 09 09 24 |pected)\|n");...$|
|00001c70| 65 72 72 6f 72 2b 2b 3b | 0d 09 09 75 6e 64 65 66 |error++;|...undef|
|00001c80| 20 24 61 72 67 3b 09 23 | 20 64 6f 6e 27 74 20 61 | $arg;.#| don't a|
|00001c90| 73 73 69 67 6e 20 69 74 | 0d 09 20 20 20 20 7d 0d |ssign it|.. }.|
|00001ca0| 09 20 20 20 20 6e 65 78 | 74 3b 0d 09 7d 0d 0d 09 |. nex|t;..}...|
|00001cb0| 69 66 20 28 20 24 74 79 | 70 65 20 65 71 20 22 73 |if ( $ty|pe eq "s|
|00001cc0| 22 20 29 20 7b 20 23 20 | 73 74 72 69 6e 67 0d 09 |" ) { # |string..|
|00001cd0| 20 20 20 20 6e 65 78 74 | 3b 0d 09 7d 0d 0d 20 20 | next|;..}.. |
|00001ce0| 20 20 7d 0d 20 20 20 20 | 63 6f 6e 74 69 6e 75 65 | }. |continue|
|00001cf0| 20 7b 0d 09 69 66 20 28 | 20 64 65 66 69 6e 65 64 | {..if (| defined|
|00001d00| 20 24 61 72 67 20 29 20 | 7b 0d 09 20 20 20 20 69 | $arg ) |{.. i|
|00001d10| 66 20 28 20 24 61 72 72 | 61 79 20 29 20 7b 0d 09 |f ( $arr|ay ) {..|
|00001d20| 09 70 72 69 6e 74 20 53 | 54 44 45 52 52 20 28 27 |.print S|TDERR ('|
|00001d30| 3d 3e 20 70 75 73 68 20 | 28 40 27 2c 20 24 70 6b |=> push |(@', $pk|
|00001d40| 67 2c 20 27 5c 27 6f 70 | 74 5f 27 2c 20 24 6f 70 |g, '\'op|t_', $op|
|00001d50| 74 2c 20 22 2c 20 5c 22 | 24 61 72 67 5c 22 29 5c |t, ", \"|$arg\")\|
|00001d60| 6e 22 29 0d 09 09 20 20 | 20 20 69 66 20 24 64 65 |n")... | if $de|
|00001d70| 62 75 67 3b 0d 09 20 20 | 20 20 20 20 20 20 65 76 |bug;.. | ev|
|00001d80| 61 6c 20 28 27 70 75 73 | 68 28 40 27 20 2e 20 24 |al ('pus|h(@' . $|
|00001d90| 70 6b 67 20 2e 20 27 5c | 27 6f 70 74 5f 27 20 2e |pkg . '\|'opt_' .|
|00001da0| 20 24 6f 70 74 20 2e 20 | 22 2c 20 5c 24 61 72 67 | $opt . |", \$arg|
|00001db0| 29 3b 22 29 3b 0d 09 20 | 20 20 20 7d 0d 09 20 20 |);");.. | }.. |
|00001dc0| 20 20 65 6c 73 65 20 7b | 0d 09 09 70 72 69 6e 74 | else {|...print|
|00001dd0| 20 53 54 44 45 52 52 20 | 28 27 3d 3e 20 24 27 2c | STDERR |('=> $',|
|00001de0| 20 24 70 6b 67 2c 20 27 | 5c 27 6f 70 74 5f 27 2c | $pkg, '|\'opt_',|
|00001df0| 20 24 6f 70 74 2c 20 22 | 20 3d 20 5c 22 24 61 72 | $opt, "| = \"$ar|
|00001e00| 67 5c 22 5c 6e 22 29 0d | 09 09 20 20 20 20 69 66 |g\"\n").|.. if|
|00001e10| 20 24 64 65 62 75 67 3b | 0d 09 20 20 20 20 20 20 | $debug;|.. |
|00001e20| 20 20 65 76 61 6c 20 28 | 27 24 27 20 2e 20 24 70 | eval (|'$' . $p|
|00001e30| 6b 67 20 2e 20 27 5c 27 | 6f 70 74 5f 27 20 2e 20 |kg . '\'|opt_' . |
|00001e40| 24 6f 70 74 20 2e 20 22 | 20 3d 20 5c 24 61 72 67 |$opt . "| = \$arg|
|00001e50| 3b 22 29 3b 0d 09 20 20 | 20 20 7d 0d 09 7d 0d 20 |;");.. | }..}. |
|00001e60| 20 20 20 7d 0d 0d 20 20 | 20 20 72 65 74 75 72 6e | }.. | return|
|00001e70| 20 28 24 65 72 72 6f 72 | 20 3d 3d 20 30 29 3b 0d | ($error| == 0);.|
|00001e80| 7d 0d 31 3b 0d 00 00 00 | 00 00 00 00 00 00 00 00 |}.1;....|........|
|00001e90| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001ea0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001eb0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001ec0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001ed0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001ee0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001ef0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001f00| 00 00 01 00 00 00 01 6e | 00 00 00 6e 00 00 00 3e |.......n|...n...>|
|00001f10| 00 0a 02 39 37 00 00 06 | 76 28 00 00 00 00 00 0a |...97...|v(......|
|00001f20| 02 39 36 00 00 06 2c ce | 00 00 00 00 00 0a 02 39 |.96...,.|.......9|
|00001f30| 0c 6e 65 77 67 65 74 6f | 70 74 2e 70 6c cc 02 00 |.newgeto|pt.pl...|
|00001f40| 00 00 54 45 58 54 4d 50 | 53 20 00 00 00 00 00 00 |..TEXTMP|S ......|
|00001f50| 00 00 54 45 58 54 4d 50 | 53 20 00 00 00 00 00 00 |..TEXTMP|S ......|
|00001f60| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001f70| 00 00 a6 ea b3 56 00 00 | 1e 05 00 00 01 ac 00 0a |.....V..|........|
|00001f80| 02 37 33 00 00 03 c1 a9 | 00 00 00 00 00 0a 02 37 |.73.....|.......7|
|00001f90| 34 00 00 03 e3 b8 00 00 | 00 00 00 0a 02 37 35 00 |4.......|.....75.|
|00001fa0| 00 03 e7 b6 00 00 00 00 | 00 0a 02 37 36 00 00 03 |........|...76...|
|00001fb0| f0 e3 00 00 00 00 00 0a | 02 37 37 00 00 03 f2 ff |........|.77.....|
|00001fc0| 00 00 00 00 00 0a 02 37 | 38 00 00 04 25 1d 00 00 |.......7|8...%...|
|00001fd0| 00 00 00 0a 02 37 39 00 | 00 04 2d ef 00 00 00 00 |.....79.|..-.....|
|00001fe0| 00 08 01 38 00 00 83 8d | 00 00 00 00 00 0a 02 38 |...8....|.......8|
|00001ff0| 30 00 00 04 5a 9e 00 00 | 00 00 00 0a 02 38 31 00 |0...Z...|.....81.|
|00002000| 00 00 00 48 00 09 4d 6f | 6e 61 63 6f 00 20 20 20 |...H..Mo|naco. |
|00002010| 20 3a 20 40 28 23 29 40 | 20 6e 65 77 67 65 74 6f | : @(#)@| newgeto|
|00002020| 70 74 2e 70 6c 09 00 06 | 00 08 00 3c 00 24 01 dd |pt.pl...|...<.$..|
|00002030| 02 3d 00 3c 00 24 01 dd | 02 3d a6 eb a7 af 00 00 |.=.<.$..|.=......|
|00002040| 1d df 00 00 1d df 00 00 | 1c 5d 01 00 00 00 00 1e |........|.]......|
|00002050| 00 3c 00 24 01 dd 02 3d | 00 3c 00 24 01 dd 02 3d |.<.$...=|.<.$...=|
|00002060| 00 00 1c 5d 00 00 00 00 | 00 00 00 00 00 00 00 00 |...]....|........|
|00002070| 01 00 00 00 01 6e 00 00 | 00 6e 00 00 00 3e 00 41 |.....n..|.n...>.A|
|00002080| 62 20 0f 6e 00 00 00 1c | 00 3e 00 00 4d 50 53 52 |b .n....|.>..MPSR|
|00002090| 00 01 00 0a 03 ed ff ff | 00 00 00 00 00 00 00 00 |........|........|
|000020a0| 03 f0 ff ff 00 00 00 4c | 00 47 94 b8 00 00 00 00 |.......L|.G......|
|000020b0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000020c0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000020d0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000020e0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000020f0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
+--------+-------------------------+-------------------------+--------+--------+